<?php
namespace app\index\controller;

class Qiudui extends Base
{
    public function index()
    {
        $category = db('category',[], false)->where('id' , 124)->find();
        //$doclist = db('article_doc' , [] , false)->where('category_id' , $cate)->order('create_time desc')->paginate(22);
        $sub = db('category',[], false)->where('parent_id' , $category['id'])->select();
        //print_r($sub);
        foreach ($sub as $k => $v){
            $sub[$k]['teams'] = db('team' , [] , false)->where('lx' , $v['id'])->limit(35)->select();
        }
        return $this->fetchHtml('index' , [
            'web_title'=> $category['web_title'] . '',
            'web_kw'   => $category['web_kw'],
            'web_desc' => $category['web_desc']. '',
            'category' => $category,
            'sub' => $sub,
        ]);
    }

    public function lists()
    {
        $id = intval(input('id'));
        $category = db('category',[], false)->where('id' , $id)->find();
        $doclist = db('team' , [] , false)->where('lx' , $category['id'])->paginate(70);
        $parent = db('category',[], false)->where('id' , $category['parent_id'])->find();
        //var_dump($category);
        return $this->fetchHtml('lists' , [
            'web_title'=> $category['web_title'] . '',
            'web_kw'   => $category['web_kw'],
            'web_desc' => $category['web_desc']. '',
            'category' => $category,
            'parent' => $parent,
            'doclist' => $doclist,
        ]);
    }

    public function info($id = 0){
        $id = intval($id);
        if($id <= 0){
            $this->redirect('index');
            exit;
        }
        $info = db('team' , [] , false)->where('id' , $id)->find();
        $category = db('category',[], false)->where('id' , $info['lx'])->find();
        $webtitle = $info['team_name'];
        return $this->fetchHtml('info',[
            'web_title' =>  $webtitle . ' - ' . $category['title'] . '',
            'web_kw' => $webtitle,
            'web_desc' => $webtitle,
            'info' => $info,
            'category' => $category
        ]);
    }


}
